#include <Attribute.hpp>
#include <GL/glew.h>

namespace Olorin
{
	namespace Graphics
	{
		/******************************************************************************************/
		/* Constructors for all classes.                                                          */
		/******************************************************************************************/
		Attribute::Attribute(const GLuint& location) { this->location = location; }
		UniformAttribute::UniformAttribute(const GLuint& location) : Attribute(location) { }
		VertexAttribute::VertexAttribute(const GLuint& location) : Attribute(location) { }
		
		/******************************************************************************************/
		/* Accessor functions                                                                     */
		/******************************************************************************************/
		const GLuint& Attribute::getLocation() const { return location; }
		
		/******************************************************************************************/
		/* The overloaded setValue functions for UniformAttribute                                 */
		/******************************************************************************************/
		void UniformAttribute::setValue(const float& value)
		{
			glUniform1f(location, value);
		}
			
		void UniformAttribute::setValue(const int& value)
		{
			glUniform1i(location, value);
		}
			
		void UniformAttribute::setValue(const Vector3& value)
		{
			glUniform3fv(location, 3, &(value[0]));
		}

		void UniformAttribute::setValue(const Texture& value)
		{
			glUniform1ui(location, value.getTextureID());
		}
		
		/******************************************************************************************/
		/* The overloaded setValue functions for VertexAttribute. Not implemented yet.            */
		/******************************************************************************************/
		void VertexAttribute::setValue(const float& value)
		{
			glVertexAttrib1f(location, value);
		}

		void VertexAttribute::setValue(const int& value)
		{
			glVertexAttribI1i(location, value);
		}

		void VertexAttribute::setValue(const Vector3& value)
		{
			glVertexAttrib3fv(location, &(value[0]));
		}

		void VertexAttribute::setValue(const Texture& value)
		{
			glVertexAttribI1ui(location, value.getTextureID());
		}
	}
}